import React, { useEffect, useState } from 'react';
import SelfHead from 'components/common/selfHead';
import { getRich } from 'ser/actions';
import './index.less';

export default function Detail({
  location: {
    query: { id },
  },
}) {
  const [obj, setObj] = useState({
    title: '',
    gmtCreate: '',
    content: '',
  });
  useEffect(() => {
    async function fetchData() {
      const res = await getRich(id);
      if (res.code === 0) {
        setObj({ ...res.rows });
      }
    }
    fetchData();
  }, []);
  return (
    <div className="detail">
      <SelfHead title={'详情'} />
      <div className="info">
        <p className="name">{obj.title}</p>
        <p>{obj.gmtCreate}</p>
        <div
          className="content"
          dangerouslySetInnerHTML={{ __html: obj.content }}
        ></div>
      </div>
    </div>
  );
}
